#!/usr/bin/env python

import nltk
from nltk.corpus import brown
from nltk import FreqDist

brown_tagged_sents = brown.tagged_sents(categories='news')
brown_sents = brown.sents(categories='news')
size = int (len(brown_tagged_sents) * 0.8)
train_data = brown_tagged_sents[:size]
test_data = brown_tagged_sents[size:]

# unigram tagger
unigram_tagger = nltk.UnigramTagger(train_data)
print unigram_tagger.evaluate(test_data)

# bigram
bigram_tagger = nltk.BigramTagger(train_data)
print bigram_tagger.evaluate(test_data)